<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/jquery.js"></script>
</head>
<body>
<h2>核酸检测系统</h2>
<form method="post" action="/medical/medicaList">
    <select name="id" id="hospitaId">
        <option value="">---请选择---</option>
    </select>
    <input type="submit" value="查询">
    <input type="button" value="添加" onclick="location.href='/toadd'">
</form>
<table border="1">
    <tr>
        <td>被检测人</td>
        <td>被检测人手机号</td>
        <td>被检测人身份证号</td>
        <td>检测机构</td>
        <td>检测日期</td>
        <td>检测结果</td>
        <td>操作</td>
    </tr>
    <tr th:each="m:${list}">
        <td th:text="${m.assayUser}"></td>
        <td th:text="${m.phone}"></td>
        <td th:text="${m.cardNum}"></td>
        <td th:text="${m.hospitalName}"></td>
        <td th:text="${#dates.format(m.assayTime,'yyyy-MM-dd')}"></td>

        <td th:text="${m.assayResult==0?'检测中':'确诊'}"></td>
        <td>
            <input th:value="${m.id}" type="hidden">
            <a th:href="@{/medical/updataMedical(id=${m.id})}"  th:if="${m.assayResult==0}">确诊</a>
        </td>
    </tr>
</table>
</body>
<script>
    $(function (){
        $.ajax({
            url:"/medical/hospital",
            type:"post",
            success:function (data){
                var op = "<option value=\"\">---请选择---</option>"
                for (let i = 0; i < data.length; i++) {
                    op+='<option value='+data[i].id+'>---'+data[i].name+'---</option>'
                }
                $("#hospitaId").html(op)
                console.log(data)
            }
        })
    })
</script>
</html>